﻿using System;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data;

namespace XLDL
{
    public class XLDL
    {
        public static DataTable XLDaTa(string lenh)
        {

            //string conct = "Data Source=.\\SQLEXPRESS;Initial Catalog=DINHTAM;Integrated Security=false;user id=sa;password=123456";
           // string conct = " Data Source=.\\SQLExpress;Persist Security Info=True;Integrated Security=SSPI;Initial Catalog=DINHTAM;user id=sa;password=123456";
            string conct = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
            SqlConnection conn = new SqlConnection(conct);
            conn.Open();
            SqlDataAdapter adp = new SqlDataAdapter(lenh, conn);
            DataTable tb = new DataTable();
            adp.Fill(tb);
            conn.Close();
            adp.Dispose();
            return tb;
        }
        public DataTable TableThongKe()
 	    {
 	        DataTable dtb = new DataTable();
 	        // Khai báo chuỗi kết nối
 	        string conct = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
 	        SqlConnection Conn = new SqlConnection(conct);
 	        try
 	        {
 	             // Mở kết nối
 	            Conn.Open();
 	            DataSet ds = new DataSet();
 	            SqlCommand cmdUpd = new SqlCommand("spThongKe_Edit", Conn);
 	            cmdUpd.CommandType = CommandType.StoredProcedure;
 	            SqlDataAdapter da = new SqlDataAdapter(cmdUpd);
 	            // Đổ dữ liệu vào DataSet
 	            da.Fill(ds);
 	            dtb = ds.Tables[0];
 	        }
 	        catch { }
 	        finally
 	        {
 	            if (Conn.State == ConnectionState.Open)
 	                Conn.Close();
 	            Conn.Dispose();
 	        }
 	        return dtb;
 	    }
	}
}
